Skip to content

fix: suppress JSON output for describe affected --upload#2284

Merged
aknysh merged 6 commits intomainfrom
osterman/upload-quiet-output
Apr 5, 2026
Merged

fix: suppress JSON output for describe affected --upload#2284
aknysh merged 6 commits intomainfrom
osterman/upload-quiet-output

Conversation

@osterman
Copy link
Copy Markdown
Member

@osterman osterman commented Apr 3, 2026

what

  • When --upload is used with atmos describe affected, the full affected stacks JSON is no longer dumped to the console by default
  • Pass --verbose to see the JSON output, or --file to write it to a file
  • The upload success message now includes a count of affected components (e.g. "Uploaded 12 affected component(s) to Atmos Pro")

why

  • The affected stacks JSON payload can be very large and overwhelms the console when the primary intent is just to upload
  • Users who need the output can opt in with --verbose or --file
  • The summary count provides useful feedback without the noise

references

N/A

Summary by CodeRabbit

  • Bug Fixes

    • Suppressed the large "Affected components and stacks" console output during uploads unless verbose mode or file output is requested.
    • Improved the upload success message to include the number of affected components uploaded.
  • Tests

    • Added unit tests covering upload/output behavior and CI event handling to validate verbose, file-output, and upload scenarios.

When --upload is used, the full affected stacks JSON is no longer dumped
to the console by default. Use --verbose to see it. The success message
now includes a count of affected components.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the size/s Small size PR label Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Dependency Review

✅ No vulnerabilities or license issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 0f97a4c.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@osterman osterman added the patch A minor, backward compatible change label Apr 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

Suppresses the large "Affected components and stacks" console view during uploads unless verbose mode or an output file is requested, and changes the upload success message to include the number of affected components. Adds unit tests covering upload/output control flow and upload payload assertions.

Changes

Cohort / File(s) Summary
Upload output & UI
internal/exec/describe_affected.go
Make viewWithScroll(...) conditional: run only when `!args.Upload
Tests
internal/exec/describe_affected_test.go
Update CI pull_request fixture assertions (head SHA/base ref). Add unit tests for uploadableQuery: assert suppression of console output when uploading without verbose/output file; assert output when verbose; assert OutputFile triggers write and that the HTTP upload payload contains expected fields (HeadSHA/BaseSHA, repo owner/name, stacks/components).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • aknysh
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: suppressing JSON output during upload operations, which is the core fix implemented in the code changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/upload-quiet-output

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 3, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add two tests proving that:
- Upload path is reached when output is suppressed (Upload=true, Verbose=false)
- Output is shown when verbose is enabled (Upload=true, Verbose=true)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added size/m Medium size PR and removed size/s Small size PR labels Apr 3, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/exec/describe_affected_test.go (1)

2079-2168: Consider adding a test for OutputFile scenario.

The new conditional in uploadableQuery has three branches: !args.Upload, args.Verbose, and args.OutputFile != "". The tests cover the first two but not the third. A test verifying that output is shown when Upload=true, Verbose=false, and OutputFile is set would complete the coverage.

Example test case
// TestUploadShowsOutputWhenFileSet verifies that when --upload and --file are both set,
// the JSON output is written to file (printOrWriteToFile is called).
func TestUploadShowsOutputWhenFileSet(t *testing.T) {
	printCalled := false

	d := describeAffectedExec{
		atmosConfig: &schema.AtmosConfiguration{},
		printOrWriteToFile: func(atmosConfig *schema.AtmosConfiguration, format, file string, data any) error {
			printCalled = true
			return nil
		},
		IsTTYSupportForStdout: func() bool { return false },
		pageCreator:           pager.New(),
	}

	headRef := plumbing.NewHashReference("refs/heads/feature", plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
	baseRef := plumbing.NewHashReference("refs/heads/main", plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"))

	affected := []schema.Affected{
		{Component: "vpc", Stack: "dev"},
	}

	err := d.uploadableQuery(
		&DescribeAffectedCmdArgs{
			Upload:      true,
			Verbose:     false,
			OutputFile:  "/tmp/affected.json",
			Format:      "json",
			CIEventType: "pull_request",
			CLIConfig:   &schema.AtmosConfiguration{},
		},
		"https://github.com/example/repo.git",
		headRef,
		baseRef,
		affected,
	)

	assert.True(t, printCalled, "printOrWriteToFile should be called when --upload and --file are both set")
	assert.NoError(t, err)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/exec/describe_affected_test.go` around lines 2079 - 2168, The test
suite is missing coverage for the upload branch when OutputFile is provided; add
a new unit test that calls describeAffectedExec.uploadableQuery with
DescribeAffectedCmdArgs{Upload:true, Verbose:false,
OutputFile:"/tmp/affected.json", Format:"json", CIEventType:"pull_request",
CLIConfig:...} using a describeAffectedExec whose printOrWriteToFile stub flips
a boolean, then assert printOrWriteToFile was called and that uploadableQuery
returns no error; reference the same setup as
TestUploadSuppressesOutputButStillUploads/TestUploadShowsOutputWhenVerbose
(headRef, baseRef, affected, IsTTYSupportForStdout, pageCreator) to keep tests
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/exec/describe_affected_test.go`:
- Around line 2079-2168: The test suite is missing coverage for the upload
branch when OutputFile is provided; add a new unit test that calls
describeAffectedExec.uploadableQuery with DescribeAffectedCmdArgs{Upload:true,
Verbose:false, OutputFile:"/tmp/affected.json", Format:"json",
CIEventType:"pull_request", CLIConfig:...} using a describeAffectedExec whose
printOrWriteToFile stub flips a boolean, then assert printOrWriteToFile was
called and that uploadableQuery returns no error; reference the same setup as
TestUploadSuppressesOutputButStillUploads/TestUploadShowsOutputWhenVerbose
(headRef, baseRef, affected, IsTTYSupportForStdout, pageCreator) to keep tests
consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a8cc9315-6a41-4eab-a632-b60332adc9fe

📥 Commits

Reviewing files that changed from the base of the PR and between 7c0339c and 88fffe3.

📒 Files selected for processing (2)
  • internal/exec/describe_affected.go
  • internal/exec/describe_affected_test.go

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 3, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.23%. Comparing base (b51717f) to head (0f97a4c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/exec/describe_affected.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2284      +/-   ##
==========================================
+ Coverage   77.19%   77.23%   +0.04%     
==========================================
  Files        1045     1045              
  Lines       98388    98389       +1     
==========================================
+ Hits        75951    75995      +44     
+ Misses      18184    18141      -43     
  Partials     4253     4253              
Flag Coverage Δ
unittests 77.23% <60.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/exec/describe_affected.go 77.54% <60.00%> (+5.36%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

osterman and others added 2 commits April 3, 2026 19:08
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/exec/describe_affected_test.go (1)

2100-2186: Consolidate upload output mode tests into table-driven cases.

These two tests are the same harness with mode toggles (Verbose false/true). A table-driven test will reduce duplication and make future branches easier to add.

♻️ Proposed refactor sketch
+func TestUploadOutputModes(t *testing.T) {
+  cases := []struct {
+    name      string
+    verbose   bool
+    wantCalls int
+  }{
+    {name: "suppressed when upload without verbose", verbose: false, wantCalls: 0},
+    {name: "shown when upload with verbose", verbose: true, wantCalls: 1},
+  }
+
+  for _, tc := range cases {
+    t.Run(tc.name, func(t *testing.T) {
+      calls := 0
+      d := describeAffectedExec{
+        atmosConfig: &schema.AtmosConfiguration{},
+        printOrWriteToFile: func(*schema.AtmosConfiguration, string, string, any) error {
+          calls++
+          return nil
+        },
+        IsTTYSupportForStdout: func() bool { return false },
+        pageCreator:           pager.New(),
+      }
+      // ... invoke uploadableQuery with tc.verbose ...
+      assert.Equal(t, tc.wantCalls, calls)
+    })
+  }
+}

As per coding guidelines, "Use table-driven tests for testing multiple scenarios in Go."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/exec/describe_affected_test.go` around lines 2100 - 2186, Combine
the two near-identical tests TestUploadSuppressesOutputButStillUploads and
TestUploadShowsOutputWhenVerbose into a single table-driven test (e.g.,
TestUploadOutputModes) that iterates cases for Verbose=false and Verbose=true;
for each case create the describeAffectedExec with the same printOrWriteToFile
stub, IsTTYSupportForStdout, pageCreator, headRef/baseRef and affected slice,
call uploadableQuery with fields driven from the table row, and in a t.Run
subtest assert whether printCalled matches the expected value and that err is
nil; this reduces duplication and keeps the same assertions and setup while
using table rows to add future cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/exec/describe_affected_test.go`:
- Around line 2218-2250: The test only checks that the printOrWriteToFile hook
was called but not what arguments were passed; modify the closure passed as
printOrWriteToFile in the test for uploadableQuery to capture the incoming
format and file parameters (e.g., store them in local vars like gotFormat,
gotFile) and return nil, then after calling d.uploadableQuery assert that
gotFile equals the DescribeAffectedCmdArgs.OutputFile value and gotFormat equals
"json" (and optionally assert data is non-nil or contains expected content);
update references to the closure and the
DescribeAffectedCmdArgs.OutputFile/Format expectations accordingly so the
OutputFile branch is validated directly.

---

Nitpick comments:
In `@internal/exec/describe_affected_test.go`:
- Around line 2100-2186: Combine the two near-identical tests
TestUploadSuppressesOutputButStillUploads and TestUploadShowsOutputWhenVerbose
into a single table-driven test (e.g., TestUploadOutputModes) that iterates
cases for Verbose=false and Verbose=true; for each case create the
describeAffectedExec with the same printOrWriteToFile stub,
IsTTYSupportForStdout, pageCreator, headRef/baseRef and affected slice, call
uploadableQuery with fields driven from the table row, and in a t.Run subtest
assert whether printCalled matches the expected value and that err is nil; this
reduces duplication and keeps the same assertions and setup while using table
rows to add future cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 43540841-5eb4-413e-b778-590aef0d10f9

📥 Commits

Reviewing files that changed from the base of the PR and between 88fffe3 and a3605cf.

📒 Files selected for processing (1)
  • internal/exec/describe_affected_test.go

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/exec/describe_affected_test.go (1)

2728-2732: Conditional assertion may weaken test guarantees.

The if describe.SHA == "" branch makes this test pass for two different outcomes. For a pull_request event with the given payload, the expected behavior should be deterministic. If the provider can legitimately return either Ref or SHA, consider splitting into separate sub-tests or documenting why both outcomes are acceptable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/exec/describe_affected_test.go` around lines 2728 - 2732, The test
currently allows two different outcomes by using "if describe.SHA == \"\"" which
weakens guarantees; change the test to be deterministic by either asserting
exactly the expected field (Ref or SHA) for the specific pull_request payload or
split into two explicit sub-tests that validate each allowed provider behavior
separately: locate the test that reads the describe variable (references to
describe.SHA and describe.Ref) and replace the conditional with one of two fixes
— (A) assert the single expected value (e.g., require.Equal on describe.SHA or
describe.Ref) for this payload, or (B) create two sub-tests
(t.Run(\"returns-sha\", ...) and t.Run(\"returns-ref\", ...)) each with a
fixture or mocked provider that deterministically returns SHA or Ref and assert
the corresponding field; ensure the assertions are precise (use require/expect)
and add a short comment explaining why both behaviors are tested if you choose
option B.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/exec/describe_affected_test.go`:
- Around line 2728-2732: The test currently allows two different outcomes by
using "if describe.SHA == \"\"" which weakens guarantees; change the test to be
deterministic by either asserting exactly the expected field (Ref or SHA) for
the specific pull_request payload or split into two explicit sub-tests that
validate each allowed provider behavior separately: locate the test that reads
the describe variable (references to describe.SHA and describe.Ref) and replace
the conditional with one of two fixes — (A) assert the single expected value
(e.g., require.Equal on describe.SHA or describe.Ref) for this payload, or (B)
create two sub-tests (t.Run(\"returns-sha\", ...) and t.Run(\"returns-ref\",
...)) each with a fixture or mocked provider that deterministically returns SHA
or Ref and assert the corresponding field; ensure the assertions are precise
(use require/expect) and add a short comment explaining why both behaviors are
tested if you choose option B.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b50ca35e-c0b6-4c77-9203-9f5844935593

📥 Commits

Reviewing files that changed from the base of the PR and between a3605cf and 0f97a4c.

📒 Files selected for processing (1)
  • internal/exec/describe_affected_test.go

@aknysh aknysh merged commit d0e8092 into main Apr 5, 2026
56 checks passed
@aknysh aknysh deleted the osterman/upload-quiet-output branch April 5, 2026 02:40
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

These changes were released in v1.215.0-rc.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants